package cn.edu.wynu.oop.package1;

public class Student {
    private int age;
    private String name;

    public int getAge() {
        if (age == 0) {
            System.out.println("年龄未初始化");
            return 0;
        }
        return age;
    }

    public String getName() {
        return name;
    }

    public void setAge(int age) {
        if (age < 0 || age > 200) {
            System.out.println("年龄有误！");
            return;
        }
        this.age = age;
    }

    public Student() {
        System.out.println("构造器调用");
    }

    public void setName(String name) {
        this.name = name;
    }
}
